<?php
require_once('security.php');
    
  /*echo '<br /><p><b>Image and text files that are in imgtxt folder:</b></p>';
  $dirname = "../imgtxt";
  $dh = opendir($dirname);
  while (false !== ($file = readdir($dh))) {
    if ((strstr($file, '.txt')) ||(strstr($file, '.jpg')) || (strstr($file, '.bmp'))|| (strstr($file, '.jpeg')) || (strstr($file, '.gif')) || (strstr($file, '.png'))) {
      print '<a href="../imgtxt/' . $file . '" title="View">' . $file . '</a><br />';
    }
  }
  closedir($dh);*/
  
  if (isset($_POST['submit'])) { // Handle the form

    // Specify the image file
    $imagefile = '../imgtxt/' . $_POST['delete'];
		
    // Check for existence of file
    if (file_exists($imagefile . '.txt') || file_exists($imagefile . '.jpg') || file_exists($imagefile . '.bmp') || file_exists($imagefile . '.jpeg') || file_exists($imagefile . '.gif') || file_exists($imagefile . '.png')) {
      unlink($imagefile . '.txt');
	  unlink($imagefile . '.jpg');
	  unlink($imagefile . '.bmp');
	  unlink($imagefile . '.jpeg');
	  unlink($imagefile . '.gif');
	  unlink($imagefile . '.png');
	  
      $response = 'Success. <b>' . $_POST['delete'] . '</b> was deleted.<br />';
    } else {
      $response = 'Sorry, <b>' . $_POST['delete'] . '</b> does not exist. Try another.<br />';
    }
  }

?>

<?php $thisPage = "deleteimage"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Delete an image</title>
<meta name="robots" content="noindex,nofollow" />
<?php require_once('theme/admintheme.php');?>
</head>
<body>

<div id="wrap">



<?php include_once('navigation.php'); ?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
name of the file to be deleted (eg image)<br />
<input type="text" name="delete" id="delete" size="40" value="<?php if (isset($_POST['submit'])) echo $_POST['delete']; ?>" maxlength="60" />
<br />
<input type="submit" name="submit" value="Delete image" />
</form>

<?php if (isset($response)) {echo $response;} ?>

<?php  
    
  echo '<br /><p><b>Image and text files that are in imgtxt folder:</b></p>';
  $dirname = "../imgtxt";
  $dh = opendir($dirname);
  while (false !== ($file = readdir($dh))) {
    if ((strstr($file, '.txt')) ||(strstr($file, '.jpg')) || (strstr($file, '.bmp'))|| (strstr($file, '.jpeg')) || (strstr($file, '.gif')) || (strstr($file, '.png'))) {
      print '<a href="../imgtxt/' . $file . '" title="View">' . $file . '</a><br />';
    }
  }
  closedir($dh);
  

?>

</div>

</body>
</html>
